package com.myway.components.esb;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * @ClassName: ESBConfig <br/>
 * @Description: ESB接口配置类 <br/>
 * @CreateDate: 2016年5月17日 下午6:39:35 <br/>
 * @author Toby
 * @version V1.0
 */
public class ESBConfig {

	private static final Logger log = Logger.getLogger(ESBConfig.class);

	private static final String proName = "ctx-interface.properties";

	private static HashMap<String, Integer> map ;

	private static Properties properties = new Properties();

	/**
	 * 初始化配置信息
	 */
	static {
		InputStream resourceAsStream = ESBConfig.class.getClassLoader().getResourceAsStream(proName);
		try {
			// 加载配置文件
			properties.load(resourceAsStream);
			//放到了map
//			map = new HashMap<String, Integer>((Map)properties);
		} catch (IOException e) {
			log.error("ctx-interface.properties加载失败:" + e);
			throw new RuntimeException(e);
		} finally {
			try {
				resourceAsStream.close();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

	public static String getConfig(String id){
		if(null!=properties){
			return properties.getProperty(id);
		}
		return null;
	}
	
	
}
